//
//  LVSessionManageVc.m
//  LEVE
//
//  Created by 上官惠阳 on 2017/3/10.
//  Copyright © 2017年 dashuju. All rights reserved.
//

#import "LVSessionManageVc.h"
#import "HYVerCustomSlideViewController.h"
#import "LVSessionListViewController.h"
#import "HYOptionalView.h"

@interface LVSessionManageVc ()<HYVerCustomSlideViewControllerDelegate,HYVerCustomSlideViewControllerDataSource>
@property (nonatomic, strong) HYVerCustomSlideViewController *verSlideViewController;
@property (nonatomic, strong) HYOptionalView *optionalView;

@end

@implementation LVSessionManageVc

- (void)viewDidLoad {
    [super viewDidLoad];

    WeakSelf(weakSelf);
    self.optionalView.titles = @[@"Talk",@"Leve"];
    self.optionalView.optionalViewItemClickHandle = ^(HYOptionalView *optialView, NSString *title, NSInteger currentIndex){
        weakSelf.verSlideViewController.seletedIndex = currentIndex;
    };

    [self HY_setUpNavLeftItemTitle:nil itemImage:@"im_menu" handle:^(NSString *leftItemTitle) {

        
    }];

    [self HY_setUpNavRightItemTitle:nil itemImage:@"im_add_friend" handle:^(NSString *leftItemTitle) {


    }];

    self.navigationItem.titleView = self.optionalView;

    [self.verSlideViewController reloadData];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.navigationController.navigationBar.barTintColor = KMainColor;
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationOnOrOffScrollMainView" object:@[@(YES),@(0)]];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationOnOrOffScrollMainView" object:@[@(NO),@(0)]];
}
#pragma mark HYVerCustomSlideViewControllerDelegate
- (void)verCustomSlideViewController:(HYVerCustomSlideViewController *)slideViewController slideIndex:(NSInteger)slideIndex
{

}
#pragma mark HYVerCustomSlideViewControllerDataSource
/** 子控制器*/
- (UIViewController *)verSlideViewController:(HYVerCustomSlideViewController *)slideViewController viewControllerAtIndex:(NSInteger)index
{
    LVSessionListViewController *listVc = [[LVSessionListViewController alloc] init];

    return listVc;
}
/** 子控制器数量*/
- (NSInteger)numberOfChildViewControllersInVerSlideViewController:(HYVerCustomSlideViewController *)slideViewController
{
    return 2;
}
- (void)verCustomSlideViewController:(HYVerCustomSlideViewController *)slideViewController slideOffset:(CGPoint)slideOffset{
    self.optionalView.contentOffset = slideOffset;
}
#pragma mark 创建滚动视图控制器
- (HYVerCustomSlideViewController *)verSlideViewController {
    if (!_verSlideViewController) {
        HYVerCustomSlideViewController *slide = [[HYVerCustomSlideViewController alloc] init];
        slide.isTransversal = YES;
        slide.canScroll = NO;
        [self addChildVc:slide];
        _verSlideViewController = slide;
        slide.delgate = self;
        slide.dataSource = self;
    }
    return _verSlideViewController;
}
#pragma mark 滑动条
- (HYOptionalView *)optionalView {
    if (!_optionalView) {
        HYOptionalView *optional = [[HYOptionalView alloc] init];
        optional.showBottomLine = NO;
        optional.frame = CGRectMake(0, 0, 120, 40);
        _optionalView = optional;
        optional.backgroundColor = kClearColor;
        optional.normalColor = kRGBColor(181,186,255);
        optional.seletedColor = kWhiteColor;
    }
    return _optionalView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
